#include<stdio.h>
#include<stdlib.h>


void get(int a, int b)
{
	a = abs(a);
	b = abs(b);
	int temp = 0;
	
	if(a<b)
	{
		temp = a;
		a = b;
		b = temp;
	}
	
	while(b!=0)
	{
		temp = a%b;
		a = b;
		b = temp;
	}
	
	printf("%d\n",a);
}


int main()
{
	int a, b;
	scanf("%d%d",&a,&b);
	get(a,b);
	
	return 0;
}
